/**
*      author: Y_Yao
*      created: 2025-04-06 17:28:49
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 7;
int n;
int a[N];

void solve()
{
    cin >> n;
    int cnt1 = 0;
    int mi = INF;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
        mi = min(a[i],mi);
    }
    for(int i = 1;i <= n;i++)
    {
        if(a[i] == mi) cnt1++;
    }
    if(cnt1 >= 2)
    {
        cout << "YES" << endl; 
        return;
    }

    unordered_set<int> s;
    int prev = 0;
    int c;
    for(int i = 1;i <= n;i++)
    {
        if(a[i] == mi) continue;
        if(a[i] % mi == 0)
        {
            s.insert(a[i]);
            if(prev != 0)
            {
                c = gcd(c,prev);
                prev = a[i];
            }
            else prev = c = a[i];
        }
    }
    // cout << c << endl;
    if(c != mi)
    {
        cout << "NO" << endl;
        return;
    }
    if(s.size() >= 2)
    {
        cout << "YES" << endl;
        return;
    }
    cout << "NO" << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}